/**
 * SqLiteHelper
 * 
 * 05/12/2013
 * 
 * Copyright GPL
 */
package com.jtmproject.javiertejedor.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
 
/**
 * this is a class to create a database
 * @author Javier Tejedor
 * @thanks pello xabier altadill
 */
class SqLiteHelper extends SQLiteOpenHelper {
	
	public static final String NAME_DB = "secrets.db";
	
	public static final int VERSION_BD = 1;

	public static final String SQLCREATE = "create table secrets "+ 
			 " (_id integer primary key autoincrement, " +
			 " secret text not null);";

	/**
	 * Constructor
	 * @param contexto 
	 */
	public SqLiteHelper(Context contexto) {
		super(contexto, NAME_DB, null, VERSION_BD);
	}

	/* (non-Javadoc)
	 * @see android.database.sqlite.SQLiteOpenHelper#onCreate(android.database.sqlite.SQLiteDatabase)
	 */
	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("DROP TABLE IF EXISTS secrets");
		db.execSQL(SQLCREATE);
	}

	/* (non-Javadoc)
	 * @see android.database.sqlite.SQLiteOpenHelper#onUpgrade(android.database.sqlite.SQLiteDatabase, int, int)
	 */
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

		db.execSQL("DROP TABLE IF EXISTS secrets");

		onCreate(db);
	}
	
}